//
//  BaseTableViewController.swift
//  CXWeibo
//
//  Created by mac on 15/6/6.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    /// 用户登录标记
    var userLogon = false
    
    /// 访客登录试图
    var visitorLoginView: VisitorLoginView?
    
    override func loadView() {
        
        // 如果已经登录，直接返回
        if(userLogon){
            
            super.loadView()
            return
        }
        
        // 替换根试图
       visitorLoginView = NSBundle.mainBundle().loadNibNamed("VisitorLoginView", owner: nil, options: nil).last as? VisitorLoginView
        
        
        //设置代理
        visitorLoginView?.delegate = self
        
        view = visitorLoginView
        
        // 添加导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "didSeledRegisterButton")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "didSeledLoginButton")
        
    }
    
    
    /// MARK: - 访客试图协议方法
    /// 用户登录
    func didSeledLoginButton() {
        
        println("用户登录")
    }
    
    /// 用户注册
    func didSeledRegisterButton() {
        
        println("用户注册")
    }
    


}
